home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / AudioTimeScaleLib 1.1 / README InTimePro™ next >
Text File  |  1996-05-28  |  20KB  |  280 lines

  1. InTimePro™
  2. Professional Audio Timebase Conversion Library
  3. for Metrowerks CodeWarrior™ PPC
  4.  
  5.  
  6. developed by:
  7.  
  8. Stephan M. Sprenger
  9. PROSONIQ PRODUCTS SOFTWARE GmbH
  10. Audio Research and Development
  11. Hauptstrasse 24
  12. D-69151 Neckargemuend
  13. Germany
  14.  
  15. Fax: +49 6223 9206-38 or -21 
  16. Internet: prosoniq@u-connect.com
  17.                                                                                 sms@prosoniq.com
  18.  
  19.                                                                                 http:// www.u-connect.com/shtml/prosoniq.shtml
  20.                                                                                 http:// www.prosoniq.com (under construction)
  21.  
  22.  
  23.  
  24. Product Information
  25.  
  26. InTimePro provides you with the ability to digitally change the length of a soundfile without affecting its pitch. Normally a change in the duration of a sampled sound using transposition (altering the sample rate) also means a change in pitch. InTimePro changes the duration using an intelligent Timebase Compression/Expansion algorithm leaving the actual tonal information untouched. This is a very useful feature if you plan to synchronize spoken text to a movie or if you need to adapt the tempo of a vocal track to a song (e.g. for remixing purposes). You may also find it useful for speech recognition and audio research purposes.
  27.  
  28. InTimePro implements a highly optimized coding of the "TIDE" algorithm developed by Stephan M. Sprenger in 1994 especially adapted for Power Macintosh. It supports both RAM- and disk-based applications and is very easy to include into your DSP projects  since the actual processing is performed using only 3 calls to the InTimePro routine. You will find an example of how to include InTimePro into your DSP projects along with a detailed description of its parameters below. InTimePro can be used with any 8-24 bit, mono, big-endian sample data of any sample rate, but will work best with 16 bit material sampled at 44.1kHz. It is optimized to achieve optimum results with a wide variety of audio signals but performs best when used with material having a simple harmonic structure (such as voice and single instruments). The algorithm does not alter the internal timing structure of the audio material in any way thus providing an accurate time compression/expansion tool for applications where timing is critical. Also, high quality pitch conversion for changing pitch without affecting sample length has already been included and can be turned on and off by simply setting scale to an appropriate value (s.b.). 
  29.  
  30. This InTimePro package includes a C- and C++ PowerMac native Library for use with Metrowerks CodeWarrior™ Version 8 or higher. A 68k-Macintosh version will not be released since we will discontinue to support this platform in the near future. Please note that this is no demo but a full-feature DSP library that provides you with a professional audio timebase conversion tool previously only available in expensive DSP applications. It is intended for use in your own DSP projects, commercial or non-commercial, to the conditions given below.
  31.  
  32. With this library, we primarily want to
  33.  
  34. 1. support developers who intend to write third party plug-ins for the sonicWORX DSP software platform
  35.  
  36. 2. make high quality audio timebase conversion available to developers and researchers who need to use such techniques in their (not necessarily audio-related) projects.
  37.  
  38. 3. support the development of high-quality multimedia and audio applications on the PowerMac platform
  39.  
  40. 4. provide an example for quality evaluation to our development partners and companies interested in licensing other PROSONIQ algorithms for the PowerMac and other platforms. 
  41.  
  42.  
  43.  
  44. Important: You may include this library and its routines into your DSP project under the following conditions:
  45.  
  46.  
  47.  
  48.  
  49. License Agreement
  50.  
  51. Carefully read all the terms and conditions of this license agreement prior to using this package. Use of all or any portion of this package indicates your agreement to the following terms and conditions.
  52.  
  53. PROSONIQ PRODUCTS SOFTWARE GmbH grants you, the user, a non-exclusive license to use the software in this package (the "Software"), under the terms and conditions stated in this agreement.
  54.  
  55. You may:
  56. 1. use the Software and its routines for your own DSP projects as long as the "About" dialog and all accompanying documentation (including the User's Manual and any printed documentation) of your software contain the exact following statement:
  57.  
  58. "This software uses the InTimePro™ time scaling library developed by Stephan M. Sprenger, ©1994-96 PROSONIQ PRODUCTS SOFTWARE GmbH, Germany. PROSONIQ PRODUCTS is an affiliated member of the Under Cover Music Group GmbH & Co. Multimedia KG."
  59.  
  60. You may not:
  61. 1. make alterations or modifications to the Software (or any copy) or disassemble or decompile the Software (or any copy), or otherwise attempt to discover the source code of the Software.
  62. 2. sublicense, lease, lend, rent or grant other rights in all or any portion of the Software (or any copy) to others.
  63. 3. make verbal or media translations of this documentation.
  64.  
  65. TERM: This agreement is effective until terminated. You may terminate it at any time by destroying the Software together with all copies in any form (including the portions of your projects that include or use it). It will also terminate if you fail to comply with any term or condition in this agreement.
  66.  
  67. PROSONIQ PRODUCTS SOFTWARE GmbH makes no warranty or representation, either express or implied, with respect to InTimePro, its quality, performance or fitness for a particular purpose. You, the user assume the entire risk as to its quality and performance. In no event will PROSONIQ PRODUCTS SOFTWARE GmbH be liable for direct, indirect, special, incidental or consequential damages arising from any defect in any version of InTimePro or its documentation, even if advised of the possibility of such damages.
  68.  
  69.  
  70. Please note: you will receive technical support and further updates of this library only if you comply to the above license agreement and register with us by sending a copy of your software that uses the InTimePro routines to the address given above. 
  71.  
  72. There are more InTimePro features currently under consideration including 
  73.  
  74. 1. A version with external memory management making parallel processing of more than one soundfile possible at a time. With the current version of InTimePro only one file can be processed simultaneously since InTimePro uses static variables within the library and is unable to distinguish between calls from different documents. 
  75.  
  76. 2. High-quality non-harmonic signal timebase conversion for use with drum loops and other non-harmonic signals that are otherwise difficult to time expand/compress. 
  77.  
  78. 3. Formant Shaping allowing for a pitch transposition that does not change the basic timbre of a vocal recording
  79.  
  80. 4. Mixdown Timebase Conversion allowing to change the timebase of a complete digitized song. 
  81.  
  82. These features are not included with this version of InTimePro but may be made available to registered developers in the near future. 
  83.  
  84.  
  85.  
  86. How to include InTimePro
  87.  
  88. To use the InTimePro routines in your project, simply add the "InTime.C++.PPC.Lib" and "InTime.C.PPC.Lib" files to your Metrowerks CodeWarrior™ project by using the "Add files" menu entry or by dragging the Library icon into the project window. 
  89.  
  90. Now open your C/C++ source file in which you plan to include the InTimePro routines and include the "InTimePro.h" header file at the beginning of your source text. Make sure the "Preferences…" settings are properly set so CodeWarrior™ can find the files.
  91.  
  92. Please make sure that your program allows only one file to be processed by InTimePro at a time. Otherwise, InTimePro will show strange behaviour and scramble your sample data. This is not a bug. It stems from the fact that InTimePro needs accessing static variables within the library which are crucial to InTimePro's functionality in this version.
  93.  
  94.  
  95.  
  96. The InTimePro parameters
  97.  
  98. There is a number of parameters that must be passed to the routine and affect both quality and operation of the algorithm. 
  99.  
  100. The prototype of the InTimePro routine is: 
  101.  
  102.  
  103. long InTimePro(short mode, long *iodata, long *writeFrames, long startFrame, float percent, short scale, short quality, short adjust);
  104.  
  105. InTimePro() returns the new counter value for the next file or memory read operation. If you pass the frame number of the first frame to be processed to InTimePro() using the startFrame variable, the return value is the absolute frame (not byte unless your audio data is 8 bit) number of the next frame to be read from the file. For RAM-based applications the behaviour is identical. 
  106.  
  107. mode
  108. This parameter defines the operation mode of the InTimePro() routine and must be set to predefined values each time InTimePro() is called. The setting for this parameter is shown in the example source code below.
  109.  
  110. *iodata
  111. This must be the address of the I/O buffer containing the input data read from the file (or the respective segment in RAM). Input data is altered between calls for optimum memory efficiency. If you call InTimePro() with the ITPFLUSH mode selected, the data in iodata[] is replaced by the processed output data. Please note that the array must be of size long since the additional bits are needed as headroom during processing and when working with 24bit sample data. The size of iodata[] must be 4*ILEN elements in any mode with the first 2*ILEN elements filled with the input audio data. ILEN is defined in "InTimePro1.0.h" and currently has a value of 1024.
  112.  
  113. *writeFrames
  114. This long returns the number of elements in the iodata[] array containing valid output data. This is only important if InTimePro() is called with the ITPFLUSH mode selected and can be used as a 'size' parameter for a subsequent call to a routine writing the processed data to the output (not provided).
  115.  
  116. startFrame
  117. Since the value returned by InTimePro() is always the absolute value of the input frame counter from the beginning of the file (or RAM address), you must specify the absolute address of the beginning of the segment to be processed. If you - for example - have a file and want InTimePro to process it starting from sample #1332 (of arbitrary size), you must pass a startFrame value of 1332 to InTimePro(). Usually you may want to process the whole file (RAM segment), so you pass a 0 (or the start RAM counter offset where the audio data begins, respectively)  to InTimePro().
  118.  
  119. percent
  120. This parameter defines the amount by which the audio data is timebase compressed (percent < 100) or expanded (percent > 100). If the scale variable is set to PITCH, this parameter defines the amount by which the pitch is scaled. In this case, a value <100 means transposing down while a value >100 means transposing up. A setting of 200 will produce an output sample with the pitch one octave above the original basic pitch. The percent value is limited to a minimum of 20 percent and has an unlimited maximum. However, we recommend allowing the user to set the percent value only in a range from 50 to 250 percent. You may experience audible artifacts when using high expansion rates (>130 percent [mixdown signals] and > 200 percent [single instruments] on the average). If you are not satisfied with the results, try breaking up the expansion process into more than one pass at lower expansion ratios or try changing the adjust parameter setting.
  121.  
  122. scale
  123. If you call InTimePro() with this parameter set to PITCH, pitch scaling is performed instead of timebase conversion. The pitch of the recording is changed by the amount specified by 'percent'. A setting of 200 will produce an output file having a pitch twice as high as the original input file. The relationship between percent and semitones is given by the formula
  124.  
  125.         percent = 100.0 * 2 ^ (semitones/12)
  126.  
  127. or, to be more precise, 
  128.  
  129.         percent = 100.0*2 ^ ((semitones/12) + (cents/1200))
  130.  
  131.  
  132. quality 
  133. Allows you to choose from currently 4 different quality settings (Q_POOR, Q_BETTER, Q_GOOD and Q_EXCELL).The quality setting is parameter congruential, meaning that artifacts are always reduced at higher quality and not just shifted to another location in the sound. The default value for this parameter should always be Q_GOOD since it offers high quality at a reasonable processing speed.
  134.  
  135. adjust 
  136. This parameter (also known as "Tracking Strength" from the sonicWORX® Time/Pitch Scaling PlugIns) affects the adaptability of the algorithm to a certain type of material. Lower values will work well with audio signals consisting of more than one instrument (i.e. material not having a clearly identifiable basic period or more than one fundamental frequency). The default value for this parameter should always be 5 - when processing voice and simple waveforms one should try to set it to the highest value possible without artifacts; when processing complex signals one should try using lower values.
  137.  
  138.  
  139.  
  140.  
  141. Source code example
  142.  
  143. The following code shows how the main loop of a DSP application should look like in standard C when using InTimePro. We assume that there are two routines handling the input and output data. The routines GetSampleData() and PutSampleData() (not provided) read or write the sample data from and to the in-/output. 
  144.  
  145. long GetSampleData(long framePos, long size, long *inbuffer);
  146.  
  147. reads from the input (either a file or a RAM address) converting the word size of the samples read to the required 32bit long format and returns the number of samples actually read. If the end of the file is reached a 0 is returned. framePos determines the absolute address of the first sample to be read from the file (for use with read() and related routines it has to be multiplied with sizeof(short) in the case of 16bit audio data to produce the exact byte position in the file). size determines, how many samples should be read (for InTimePro this must be set to 2*ILEN in any case). Note: for use with read() and related routines the size value has to be multiplied with sizeof(short) in the case of 16bit audio data to produce the exact byte count to be read from the file. Finally, inbuffer[] holds the input data.
  148.  
  149. long PutSampleData(long framePosOut, long size, long *outbuffer);
  150.  
  151. writes to the output (either a file or a RAM address) converting the word size of the samples back to the required output format. framePosOut determines the absolute address of the first sample to be written  to the file (for use with write() and related routines it has to be multiplied with sizeof(short) in the case of 16bit audio data to produce the exact byte position in the file). size determines, how many samples should be written, the wrFrames value should be used. Note: for use with write() and related routines the size value has to be multiplied with sizeof(short) in the case of 16bit audio data to produce the exact byte count to be written to the file. Finally, outbuffer[] holds the output data returned from InTimePro() in ITPFLUSH mode.
  152.  
  153.  
  154. #include "InTimePro1.0.h"
  155. .
  156. .
  157. .
  158.  
  159. long data[4*ILEN];
  160. long wrFrames, framePos;
  161. long startFrame = 0, ret;                                           /* startFrame 0 means process entire file */
  162. float percent = 125.0;                                                  /* user parameter */
  163. short quality = Q_GOOD;                         /* user parameter */
  164. short scale = TIMEBASE;                     /* user parameter */
  165. short adjust = 5;                                                                                       /* user parameter */
  166. .
  167. .
  168. .
  169.  
  170. /* first, initialize InTimePro */
  171. InTimePro(ITPINIT, indata, &wrFrames, startFrame, percent, scale, quality, adjust);
  172.  
  173. do{
  174.    /* first call to InTimePro returns frame position of next read */
  175.    framePos = InTimePro(ITPSTEP, data, &wrFrames, startFrame, percent, scale, quality, adjust);
  176.    ret = GetSampleData(framePos, 2*ILEN, data);
  177.  
  178.    /* second call to InTimePro also returns frame position of next read */
  179.    framePos = InTimePro(ITPPROCESS, data, &wrFrames, startFrame, percent, scale, quality, adjust);
  180.    ret = GetSampleData(framePos, 2*ILEN, data);
  181.  
  182.    /* now the processed data is copied into iodata[] and can be output */
  183.    InTimePro(ITPFLUSH, data, &wrFrames, startFrame, percent, scale, quality, adjust);
  184.    PutSampleData(framePosOut, wrFrames, data);
  185.  
  186.    /* increment the output counter to know dest. of next write */
  187.    framePosOut += wrFrames;
  188. } while (ret);
  189.  
  190.  
  191.  
  192.  
  193. When using the standard C read/write routines the the code should look somewhat like
  194.  
  195.  
  196. #include "InTimePro1.0.h"
  197. .
  198. .
  199. .
  200.  
  201. long data[4*ILEN];
  202. short buffer[4*ILEN];
  203. long wrFrames, framePos;
  204. long p; 
  205. long startFrame = 0, ret;                                   /* startFrame 0 means process entire file */
  206. float percent = 125.0;                                          /* user parameter */
  207. short quality = Q_GOOD;                 /* user parameter */
  208. short scale = TIMEBASE;             /* user parameter */
  209. short adjust = 5;                                                                               /* user parameter */
  210. /* infile and outfile used in this example must be of type FILE returned by 'open()' */
  211. .
  212. .
  213. .
  214.  
  215. /* first, initialize InTimePro */
  216. InTimePro(ITPINIT, indata, &wrFrames, startFrame, percent, scale, quality, adjust);
  217.  
  218. do{
  219.    /* first call to InTimePro returns frame position of next read */
  220.    framePos = InTimePro(ITPSTEP, data, &wrFrames, startFrame, percent, scale, quality, adjust);
  221.    lseek(infile, framePos*sizeof(short), SEEK_SET);                          /* locate framePos in file infile */
  222.    ret = read(infile, buffer, 2*ILEN*sizeof(short));                                                               /* read 2*ILEN samples in 16 bit */
  223.    for (p = 0; p < 2*ILEN; p++) data[p] = buffer[p];                                                           /* copy and convert to long int */
  224.  
  225.    /* second call to InTimePro also returns frame position of next read
  226.    framePos = InTimePro(ITPPROCESS, data, &wrFrames, startFrame, percent, scale, quality, adjust);
  227.    lseek(infile, framePos*sizeof(short), SEEK_SET);                          /* locate framePos in file infile */
  228.    ret = read(infile, buffer, 2*ILEN*sizeof(short));                                                               /* read 2*ILEN samples in 16 bit */
  229.    for (p = 0; p < 2*ILEN; p++) data[p] = buffer[p];                                                           /* copy and convert to long int */
  230.  
  231.    /* now the processed data is copied into iodata[] and can be output
  232.    InTimePro(ITPFLUSH, data, &wrFrames, startFrame, percent, scale, quality, adjust);
  233.    for (p = 0; p < wrFrames; p++) buffer[p] = data[p];                                         /* copy and convert back to short */
  234.    write(outfile, buffer, wrFrames*sizeof(short));                                                                   /* write wrFrames samples (16 bit) */
  235.  
  236.    /* need not increment the output counter because write() itself increments fpos */
  237.    /* framePosOut += wrFrames; */
  238. } while (ret);
  239.  
  240.  
  241.  
  242. These examples are for demonstration purposes only and therefore more illustrative than sophisticated. You'll have to find your personal version of this code in your particular application - you may rather use pointers instead of array indexing and malloc to allocate buffers. 
  243.  
  244.  
  245.  
  246. Other PROSONIQ products
  247.  
  248. For details on our Macintosh digital audio signal processing products (sonicWORX® Studio, Artist and Professional) contact our worldwide distributor 
  249.  
  250.  
  251. TSI GmbH
  252. attn. Mike Carroll
  253. International Sales
  254. Tel.: +49 2633 7187
  255. Fax: +49 2633 95917
  256. Internet: mc@tsi-gmbh.de
  257. USt-Id (VAT) Nr: DE 149273678
  258.  
  259.  
  260.  
  261.  
  262. Copyright and trademark information
  263.  
  264. Apple, Macintosh and Power Macintosh are registered  trademarks of Apple Computer, Inc., SGI, IRIX and Silicon Graphics are registered trademarks of Silicon Graphics Computer Systems, Inc. Metrowerks and  CodeWarrior are registered trademarks of Metrowerks, Inc. , PROSONIQ PRODUCTS, sonicWORX, InTime, InTimeFX and InTimePro are trademarks and registered trademarks of PROSONIQ PRODUCTS GmbH/Stephan M. Sprenger. 
  265.  
  266. This version of 'InTimePro' may be freely distributed and copied as long as the resource files and documentation remain unchanged from their distributed form. You are encouraged to make copies and give them to anyone you like, again so long as they remain unchanged. See the above license agreement for further details.  
  267.  
  268.  
  269. PROSONIQ PRODUCTS SOFTWARE GmbH makes no warranty or representation, either express or implied, with respect to InTimePro, its quality, performance or fitness for a particular purpose. You, the user assume the entire risk as to its quality and performance. In no event will PROSONIQ PRODUCTS SOFTWARE GmbH be liable for direct, indirect, special, incidental or consequential damages arising from any defect in any version of InTimePro or its documentation, even if advised of the possibility of such damages.
  270.  
  271.  
  272.  
  273.  
  274. [1] Stephan M. Sprenger: Introducing the TIDE Algorithm, Prosoniq Developer Notes No. 0794, Prosoniq Products Software GmbH, 1994
  275.  
  276. [2] Stephan M. Sprenger: Fast Algorithms for Audio Timebase Conversion, Prosoniq Developer Notes No. 0195, Prosoniq Products Software GmbH, 1995
  277.  
  278.  
  279.  
  280. 28.05.1996 22:39 SPRENGER